<?php
namespace app\controllers;

use app\logic\ArticleLogic;
use app\logic\CommonLogic;
use app\logic\UserLogic;

//前端文章接口
class ArticleController extends BaseController
{
    //文章列表
    public function actionGetList(){
        $article_type = $this->getQueryparams('article_type',1);
        $extend_type = $this->getQueryparams('extend_type',0);
        $articleLogic = new ArticleLogic();
        $articles = $articleLogic->getList($article_type,$extend_type);
        foreach ($articles AS &$value){
            $value['article_pic'] = \Yii::$app->params['upload']['upload_domain'].$value['article_pic'];
        }
        $this->response($articles);
    }
    //文章详情
    public function actionGetDetail(){
        $open_id = $this->getQueryparams('open_id',"");
        $userLogic = new UserLogic();
        //$user = $userLogic->findByOpenid($open_id);
        $article_id = $this->getQueryparams('article_id',0);
        $articleLogic = new ArticleLogic();
        $article = $articleLogic->getDetail($article_id);
        /*$commonLogic = new CommonLogic();
        $commonLogic->addHistory($user['user_id'],$article_id,0,$article['article_pic'],1);*/
        $userLogic->addStudyHistory($open_id,0,$article_id);
        $this->response($article);
    }

}